package com.javafactroy.kunlong.test.mockito;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.Arrays;

import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class TestMockit {

    @Mock
    DataService dataService;

    @InjectMocks
    SomeBusiness someBusiness;

    @Test
    public void testFetchAll() {
        when(dataService.getAll()).thenReturn(Arrays.asList("1", "2", "3"));
        Assert.assertEquals(someBusiness.fetchAllData(),
                Arrays.asList("1", "2", "3"));
    }
}